namespace ClothingAggregator.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MyAdvertisements",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        Photo = c.String(),
                        Price = c.Decimal(precision: 18, scale: 2),
                        AdSource = c.String(),
                        SourceString = c.String(),
                        Link = c.String(),
                        IsExact = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.MyMonitoringResults",
                c => new
                    {
                        Id = c.Int(nullable: false),
                        LastUpdate = c.DateTime(nullable: false),
                        MonitoringTaskId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.MyAdvertisements", t => t.Id, cascadeDelete: true)
                .ForeignKey("dbo.MyMonitoringTasks", t => t.MonitoringTaskId, cascadeDelete: true)
                .Index(t => t.Id)
                .Index(t => t.MonitoringTaskId);
            
            CreateTable(
                "dbo.MyMonitoringTasks",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Frequency = c.Int(nullable: false),
                        Active = c.Boolean(nullable: false),
                        CreatedAt = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MyMonitoringResults", "MonitoringTaskId", "dbo.MyMonitoringTasks");
            DropForeignKey("dbo.MyMonitoringResults", "Id", "dbo.MyAdvertisements");
            DropIndex("dbo.MyMonitoringResults", new[] { "MonitoringTaskId" });
            DropIndex("dbo.MyMonitoringResults", new[] { "Id" });
            DropTable("dbo.MyMonitoringTasks");
            DropTable("dbo.MyMonitoringResults");
            DropTable("dbo.MyAdvertisements");
        }
    }
}
